/*package com.smarttest.portal.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.smarttest.common.beans.PaginationResult;
import com.smarttest.portal.service.EventOnrefreshService;
import com.smarttest.portal.service.RefreshService;

@Controller
public class RefreshController {
	@Autowired
	RefreshService refresh ;
	@Autowired
	EventOnrefreshService eventOnrefreshService ; 
	private static boolean isOnRun = false ;
	
	@RequestMapping(value = "/refresh/range.action", method = RequestMethod.GET)
	@ResponseBody
	public JSONObject refresh (HttpServletRequest request,
			HttpServletResponse response) {
		JSONObject json = new JSONObject () ;
		//可能在前台有两个人同时进入了刷新页面，然后先后点击运行，所以在刷新前要再验证一遍isOnRun的值
		if (isOnRun) {
			json.put("isOnRun", isOnRun);
			return json ;
		} else {
			json.put("isOnRun", false);
		}
		isOnRun = true ;
		String type = request.getParameter("type");
		String data = request.getParameter("data");
		String start = request.getParameter("start");
		String end = request.getParameter("end");
		String imei = null ;
		String orgcode = null ;
		//用来记录刷新失败项，如果不为零就显示重刷按钮。刷新完成后，如果翻页查询结果，要考虑正好别人运行了程序的情况
		int fails ;
		 if (type.equals("imei")) {
			 imei = data ;
		 } else {
			 orgcode = data ;
		 }
		
		Date startTime = null ;
		Date endTime = null ;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		try {
			startTime = sdf.parse(start);
			endTime = sdf.parse(end);
			
		} catch (ParseException e) {
			e.printStackTrace();
		}
		refresh.start(startTime, endTime, imei, orgcode );
		refresh.process();
		refresh.stop();
		fails = eventOnrefreshService.getFailedNum() ;
		String pageStr = request.getParameter("toPage");
		String rowsStr = request.getParameter("pageSize");
		int page = Integer.parseInt(pageStr);
		int rows = Integer.parseInt(rowsStr);
		PaginationResult result = eventOnrefreshService.getAllImeis(page, rows);
		
		json.put("fails", fails);
		json.put("result", result);
		
		isOnRun = false ;
		
		return json ;
	}
	
	@RequestMapping(value = "/refresh/getStatus.action", method = RequestMethod.GET)
	@ResponseBody
	public JSONObject getStatus(HttpServletRequest request,
			HttpServletResponse response) {
		JSONObject json = new JSONObject();
		if ( isOnRun ) {
			json.put("isOnRun", isOnRun ) ;
		} else {
			json.put("isOnRun", false ) ;
		}
		
		String pageStr = request.getParameter("toPage");
		String rowsStr = request.getParameter("pageSize");
		int page = Integer.parseInt(pageStr);
		int rows = Integer.parseInt(rowsStr);
		PaginationResult result = eventOnrefreshService.getAllImeis(page, rows);
		json.put("result", result);
		
		return json;
	}
	
}
*/